﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_YZXXB_Manage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PopulateDrop();
        }
        txtUserID.Attributes.Add("ReadOnly", "true");
    }

    // 绑定下拉框
    public void PopulateDrop()
    {
        drpYHLX.PopulateFromEnum<YZXX.typeYH>();
        drpYHLX.Items.Insert(0, new ListItem("请选择", "0"));
        drpYZZT.PopulateFromEnum<YZXX.statusYZ>();
        drpYZZT.Items.Insert(0, new ListItem("请选择", "0"));
        drpYZLX.PopulateFromEnum<YZXX.typeYZ>();
        drpYZLX.Items.Insert(0, new ListItem("请选择", "0"));
    }

    // 获得用户名
    public string GetUserName(object UserID)
    {
        string Return = "暂无资料";
        Client objClient = Client.Get(DongDong.Common.Misc.ConvertToInt(UserID));
        if (objClient != null)
        {
            Return = "<a target='_blank' href='../../Admin/Client/Add.aspx?UserID=" + objClient.ID + "'>" + objClient.Username + "</a>";
        }
        return Return;
    }

    // 查询
    public void PopulateYZXX()
    {
        lvDate.DataSource = YZXX.GetAllByConditon(DongDong.Common.Misc.ConvertToInt(hdlUserID.Value), txtEndTimeFrom.Text, txtEndTimeFrom.Text, DongDong.Common.Misc.ConvertToInt(drpYHLX.SelectedValue), DongDong.Common.Misc.ConvertToInt(drpYZLX.SelectedValue), DongDong.Common.Misc.ConvertToInt(drpYZZT.SelectedValue), txtYZDX.Text);
        lvDate.DataBind();
    }

    protected void Pager_PreRender(object sender, EventArgs e)
    {
        if (lvDate.Items.Count == 0)
            PopulateYZXX();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        PopulateYZXX();
    }
}